﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;

using ZoneFiveSoftware.Common.Data;
using ZoneFiveSoftware.Common.Visuals;
using ZoneFiveSoftware.Common.Visuals.Fitness;


namespace PolarImport.Settings
{
    /// <summary>Register the settings page for PolarImport. </summary>
    class PolarImportExtendSettingsPage : IExtendSettingsPages
    {
        #region IExtendSettingsPages Member

        /// <summary>
        /// Retrieve a list with settings pages.
        /// </summary>
        /// <value></value>
        public IList<ISettingsPage> SettingsPages
        {
            get { return new ISettingsPage[] { new PolarImportSettingsPage() }; }
        }

        #endregion
    }

    /// <summary>
    /// The implementation of the ST-interfaces for the settings page of PolarImport
    /// </summary>
    class PolarImportSettingsPage : ISettingsPage, IDialogPage, INotifyPropertyChanged
    {
        #region ISettingsPage Member

        /// <summary>
        /// Return the unique identifier for this settings page.
        /// </summary>
        /// <value></value>
        public Guid Id
        {
            get { return new Guid("{a437d4a6-713b-43aa-b1d9-d3595f883b6e}"); }
        }

        /// <summary>
        /// Return a list of sub-pages which will appear beneath this in the settings tree.
        /// </summary>
        /// <value></value>
        public IList<ISettingsPage> SubPages
        {
            get { return new List<ISettingsPage>(); }
        }

        #endregion

        #region IDialogPage Member

        /// <summary>
        /// Return the control that is the content of the settings page.
        /// </summary>
        /// <returns></returns>
        public System.Windows.Forms.Control CreatePageControl()
        {
            if (this.control == null)
            {
                this.control = new PolarImportSettings();
            }
            return this.control;

        }

        /// <summary>
        /// Attempt to hide the page.
        /// </summary>
        /// <returns>true if successful, or false if additional
        /// user action needs to be taken before switching to another view.
        /// </returns>
        public bool HidePage()
        {
            return true;
        }

        /// <summary>
        /// Get the name of the page that appears in menu commands, etc.
        /// </summary>
        /// <value></value>
        public string PageName
        {
            get { return "PolarImport"; }
        }

        /// <summary>
        /// Display the page. Use the application reference to refresh data, selected
        /// state, etc before showing the page. The bookmark string is specific to the page implementor.
        /// </summary>
        /// <param name="bookmark"></param>
        public void ShowPage(string bookmark)
        {
        }

        /// <summary>
        /// Return the status of property page, error messages, etc
        /// </summary>
        /// <value></value>
        public IPageStatus Status
        {
            get { return null; }
        }

        /// <summary>
        /// Called when the user changes the visual theme. Update any control appearance accordingly.
        /// </summary>
        /// <param name="visualTheme"></param>
        public void ThemeChanged(ITheme visualTheme)
        {
            if (this.control != null)
                this.control.ThemeChange(visualTheme);
        }

        /// <summary>
        /// Get the name of the page that appears in the view heading.
        /// </summary>
        /// <value></value>
        public string Title
        {
            get { return "PolarImport"; }
        }

        /// <summary>
        /// Called when the user has selected a different langange. Update any resource strings accordingly.
        /// </summary>
        /// <param name="culture"></param>
        public void UICultureChanged(System.Globalization.CultureInfo culture)
        {
            if (this.control != null)
                this.control.LocalizeTexts();
        }

        #endregion

        #region INotifyPropertyChanged Member

        /// <summary>
        /// Tritt ein, wenn sich ein Eigenschaftenwert ändert.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        /// <summary>
        /// The settingspage as control.
        /// </summary>
        private PolarImportSettings control;
    }
}
